package writtenexamination.xinkangzhong;

/**
 * @author cyt
 * @create 2020-09-24 下午 3:48
 */
public class Tb {

    private static int[] arr = new int[10];
    private static int index = 0;

    public static int get(int e) {
        return arr[e];
    }

    public static void remove(int e) {
        for (int i = e; i < arr.length - 1; i++) {
            arr[i] = arr[i + 1];
        }
    }

    public static void add(int e) {
        check();
        arr[index] = e;
        index++;
    }

    public static void check() {
        int length = arr.length;
        int[] newArr = new int[10];
        if (index >= length) {
            newArr = new int[index + 10];
            for (int i = 0; i < arr.length; i++) {
                newArr[i] = arr[i];
            }
        }
        arr = newArr;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            Tb.add(i);
        }
        Tb.add(11);
        System.out.println(Tb.arr.length);

        System.out.println(Tb.get(10));

        Tb.remove(10);

        System.out.println(Tb.arr.length);
        System.out.println(Tb.get(10));
    }
}
